#include "stdafx.h"
#include ".\village.h"
#include ".\User.h"
#include <PacketStruct_AG.h>
#include <PacketStruct_AW.h>

_IMPL_POOL(Village)
Village::Village(void):
ZoneInterface(1000)
{
}

Village::~Village(void)
{
}
VOID Village::Create( KEYTYPE key,
						CODETYPE MapCode, 
						ServerSession * pServerSession )
{
	SetKey( key );
	SetMapCode( MapCode );
	SetLinkedServer( pServerSession );

	On_create();
}

VOID Village::On_create()
{
	MSG_AG_ZONE_VILLAGE_CREATE_CMD msg;
	msg.m_dwKey		= 0;
	msg.m_MapCode	= m_MapCode;
	msg.m_RoomKey	= GetKey();
	SendToLinkedServer( &msg, sizeof(msg) );
}

VOID Village::On_destroy()
{
}

VOID Village::On_readyuser( User * pUser )
{
	pUser->SetZoneState( ePRS_BEFORE_ENTER_VILLAGE );
	pUser->SetZoneKey( GetKey() );
	pUser->SetZoneType( eZONETYPE_VILLAGE );
}
VOID Village::On_enteruser( User * pUser )
{
	pUser->SetZoneState( ePRS_AT_VILLAGE );
	pUser->SetSelectedCharMapCode( GetMapCode() );
}
VOID Village::On_leaveuser( User * pUser )
{
}